/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package snippet.lab4;

import java.util.*;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author hoang.pt
 */
public class StudentDemo2 {

    public StudentDemo2() {
    }

    public static void main(String[] args) throws IOException {
        displayMenu();

    }

    /**
     * display menu
     */
    public static void displayMenu() throws IOException {

        //init choice
        int choice;
        
        InputStreamReader data = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(data);
        
        Student student = new Student();

        //loop until choice = 3
        do {
            //display menu
            System.out.println("Hanoi-Amsterdam");
            System.out.println("1. Input name");
            System.out.println("2. Display");
            System.out.println("3. Exit");
            System.out.println("------------------");
            System.out.println("Enter your choice: ");

            //read choice
            choice = Integer.parseInt(in.readLine());

            //switch choice
            switch (choice) {
                case 1:
                    student.saveStudent();
                    break;
                case 2:
                    try {
                        student.displayStudent();
                    } catch (FileNotFoundException ex) {
                    } catch (ClassNotFoundException ex) {
                    }
                    break;
                case 3:
                    System.out.println("Bye bye");
                    System.exit(0);
                default:
                    System.out.println("Invalid choice. Enter again.");
                    break;

            }
        } while (choice != 3);

    }
}
